package com.ttc.mBackup.BackupSMS;

import java.util.ArrayList;
import java.util.Date;

import android.content.Context;
import android.os.AsyncTask;
import android.text.format.DateFormat;

public class ScheduleBackup extends AsyncTask<String, String, String> {
	
	private SMSStatistics sms;
	private int backupMode;
	private String filename;
	private ArrayList<String> phoneContact;
	private int locationCode;
	
	public ScheduleBackup(Context context) {
		super();
		this.sms = new SMSStatistics(context);
		this.backupMode = DialogCode.CODE_PROGRESS_BACKUP_NEW;
		Date date = new Date();
		String time = DateFormat.format("dd-MM-yy hh.mm.ss", date.getTime()).toString();
		this.filename = "SMS-Auto-" + time;
		this.phoneContact = new ArrayList<String>();
		phoneContact.add(0, "Check all");
		this.locationCode = DialogCode.CODE_LOCATION_SD_CARD;
		
		new CustomDialog(context).storeInformation(time, filename, "Automatic");
	}

	@Override
	protected String doInBackground(String... params) {
		BackupSMS backupsms = new BackupSMS(sms, 
				phoneContact, 
				filename, locationCode, backupMode);
		int i = 0;		
		while (i != 1) {
			if(backupsms.createBackupFile()){
				i++;
			}
		}
		return null;
		
	}

	@Override
	protected void onPostExecute(String result) {
		
	}
	
}
